package com.ruoyi.laiqianba.enums;

import cn.hutool.core.util.ObjUtil;
import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Getter
public enum PostInfoEnum {

    CHANNEL_MANAGER(1L, "渠道商务", null),
    MERCHANT_MANAGER(2L, "商户商务", AccountTypeEnum.MERCHANT),
    PRODUCT_MANAGER(3L, "产品商务", AccountTypeEnum.PRODUCT),
    ACCOUNT_MANAGER(5L, "管理员", AccountTypeEnum.ACCOUNT),
    ;

    private Long postId;
    private String postName;
    private AccountTypeEnum accountType;

    PostInfoEnum(Long postId, String postName, AccountTypeEnum accountType){
        this.postId = postId;
        this.postName = postName;
        this.accountType = accountType;
    }

    /**
     * 获取当前登陆用户支持的商户信息
     */
    public static List<Map<String, String>> getAccountTypeMapList(List<Long> postIdList){
        List<Map<String, String>> resultList = new ArrayList<>();
        for (PostInfoEnum postInfoEnum : values()) {
            if (ObjUtil.isNotEmpty(postInfoEnum.getAccountType()) && postIdList.contains(postInfoEnum.getPostId())){
                Map<String, String> itemMap = new HashMap<>();
                itemMap.put("name", postInfoEnum.getAccountType().getName());
                itemMap.put("value", postInfoEnum.getAccountType().getValue());
                resultList.add(itemMap);
            }
        }
        return resultList;
    }


}
